package observer.fromKanYun;

import java.util.Observable;
import java.util.Observer;

/**
 * 观察者：观察Food
 */
class Customer implements Observer{
    private String name;

    public Customer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    @Override
    public void update(Observable o,Object arg){
        if (o instanceof Food && arg instanceof Float) {
            Food food = (Food) o;
            float price = (Float) arg;
            System.out.println("您好：" + this.name + " ," + food.getName()
                    + "的价格已经发生改变，现在的价格为：" + price + "元/斤");
        }
    }
}
